#include "RsGisLibUtiPopuImgStats.h"
#include "ExtensionManager.h"
#include "ExtensionSession.h"
#include <QVariant>

RsGisLibUtiPopuImgStats::RsGisLibUtiPopuImgStats(RsgisPortal* ClientPortal, QWidget *parent)
{
	ui = new Ui::RsGisLibUtiPopuImgStats();
	ui->setupUi(this);

	Portal = ClientPortal;

	connect(ui->pushButton_InputFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_InputFilePath_clicked()));
	connect(ui->pushButton_pyraScaleVals, SIGNAL(clicked()), this, SLOT(on_action_Button_pyraScaleValsPath_clicked()));
	connect(ui->pushButton_Excecute, SIGNAL(clicked()), this, SLOT(on_action_Button_Excecute_clicked()));

	ui->lineEdit_InputFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_pyraScaleVals->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");

	QStringList FlagList;
	FlagList.append("False");
	FlagList.append("True");
	ui->comboBox_useIgnoreVal->addItems(FlagList);
	ui->comboBox_calcImgPyramids->addItems(FlagList);

	ui->lineEdit_nodataValue->setText("0.0");
	ui->comboBox_calcImgPyramids->setCurrentIndex(0);
	ui->comboBox_useIgnoreVal->setCurrentIndex(0);

	ui->lineEdit_Priority->setText("16");
}

void RsGisLibUtiPopuImgStats::on_action_Button_InputFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_InputFilePath->setText(str.toUtf8());
}

void RsGisLibUtiPopuImgStats::on_action_Button_pyraScaleValsPath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_pyraScaleVals->setText(str.toUtf8());
}

void RsGisLibUtiPopuImgStats::on_action_Button_Excecute_clicked()
{
	QList<QVariant> SysParaList;
	SysParaList << QVariant(QString("RsGisLib"));
	SysParaList << QVariant(QString("ImageUtils"));
	SysParaList << QVariant(int(ui->lineEdit_Priority->text().toInt()));

	QList<QVariant> AlgParaList;
	AlgParaList << QVariant(QString("PopuImgStats"));
	AlgParaList << QVariant(QString(ui->lineEdit_InputFilePath->text()));
	AlgParaList << QVariant(int(ui->comboBox_useIgnoreVal->currentIndex()));
	AlgParaList << QVariant(double(ui->lineEdit_nodataValue->text().toDouble()));
	AlgParaList << QVariant(int(ui->comboBox_calcImgPyramids->currentIndex()));
	AlgParaList << QVariant(QString(ui->lineEdit_pyraScaleVals->text()));

	QVariantList ArgList;
	ArgList << (QVariant)SysParaList;
	ArgList << (QVariant)AlgParaList;

	Portal->goAhead(ArgList);
}